<rd-header>
  <rd-header-title title="Cluster overview">
    <a data-toggle="tooltip" title="Refresh" ui-sref="swarm" ui-sref-opts="{reload: true}">
      <i class="fa fa-refresh" aria-hidden="true"></i>
    </a>
  </rd-header-title>
  <rd-header-content>Swarm</rd-header-content>
</rd-header>

<div class="row">
  <div class="col-sm-12">
    <rd-widget>
      <rd-widget-header icon="fa-object-group" title="Cluster status"></rd-widget-header>
      <rd-widget-body classes="no-padding">
        <table class="table">
          <tbody>
            <tr>
              <td>Nodes</td>
              <td ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM'">{{ swarm.Nodes }}</td>
              <td ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">{{ info.Swarm.Nodes }}</td>
            </tr>
            <tr ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM'">
              <td>Images</td>
              <td>{{ info.Images }}</td>
            </tr>
            <tr ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM'">
              <td>Swarm version</td>
              <td>{{ docker.Version|swarmversion }}</td>
            </tr>
            <tr>
              <td>Docker API version</td>
              <td>{{ docker.ApiVersion }}</td>
            </tr>
            <tr ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM'">
              <td>Strategy</td>
              <td>{{ swarm.Strategy }}</td>
            </tr>
            <tr>
              <td>Total CPU</td>
              <td ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM'">{{ info.NCPU }}</td>
              <td ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">{{ totalCPU }}</td>
            </tr>
            <tr>
              <td>Total memory</td>
              <td ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM'">{{ info.MemTotal|humansize: 2 }}</td>
              <td ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">{{ totalMemory|humansize: 2 }}</td>
            </tr>
            <tr ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM'">
              <td>Operating system</td>
              <td>{{ info.OperatingSystem }}</td>
            </tr>
            <tr ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM'">
              <td>Kernel version</td>
              <td>{{ info.KernelVersion }}</td>
            </tr>
            <tr ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM'">
              <td>Go version</td>
              <td>{{ docker.GoVersion }}</td>
            </tr>
            <tr ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">
              <td colspan="2">
                <div class="btn-group" role="group" aria-label="...">
                  <a ui-sref="swarm.visualizer"><i class="fa fa-object-group space-right" aria-hidden="true"></i>Go to cluster visualizer</a>
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>

<div class="row">
  <div class="col-sm-12" ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM'">
    <nodes-ss-datatable
    title="Nodes" title-icon="fa-hdd-o"
    dataset="swarm.Status" table-key="nodes"
    order-by="name" show-text-filter="true"
    ></nodes-ss-datatable>
  </div>
  <div class="col-sm-12" ng-if="applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">
    <nodes-datatable
    title="Nodes" title-icon="fa-hdd-o"
    dataset="nodes" table-key="nodes"
    order-by="Hostname" show-text-filter="true"
    show-ip-address-column="applicationState.endpoint.apiVersion >= 1.25"
    access-to-node-details="!applicationState.application.authentication || isAdmin"
    ></nodes-datatable>
  </div>
</div>
